package com.example.exerciseextract.base;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by 阿炜啊 on 2020/7/12.
 */

public abstract class BaseActivity<P extends BasePresenter> extends AppCompatActivity implements BaseView {

    public P mPresenter;
    private int layout;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(getLayout());
        mPresenter=initPresenter();
        if (mPresenter!=null){

            mPresenter.bindView(this);
        }
        initdata();
        intaview();


    }
    //初始化界面
    protected abstract void intaview();
    //设置数据
    protected abstract void initdata();
    //添加p层
    protected abstract P initPresenter();
    //设置布局 xml
    protected abstract int getLayout();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.onDestory();
        //2.取消V和P层关联
        mPresenter = null;
    }
}
